import { createStore } from 'vuex'

const store = createStore({
    state: {
        user: {
            name: '',
            id: '',
            account: ''
        },
        role: {
            name: '',
            code: ''
        }
    },
    mutations: {
        setUser(state, user) {
            state.user = {
                account: user.username,
                name: user.fullName,
                id: user.userId
            }
        },
        setRole(state, role) {
            state.role = {
                name: role.role_name,
                code: role.role_code
            }
        }
    }
})

export default store;